﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HCFramework.API.LINQ;

namespace C
{
    public class FeedBackController
    {
        public static void Insert(FeedBack a)
        {
            HCDataContext db = new HCDataContext();
            a.InsertDate = DateTime.Now;
            db.FeedBacks.InsertOnSubmit(a);
            db.SubmitChanges();
        }

        public static void Update(FeedBack a, HCDataContext db)
        {
            db.SubmitChanges();
        }

        public static void Delete(int id)
        {
            HCDataContext db = new HCDataContext();
            FeedBack a = db.FeedBacks.Where(
                ik => ik.FeedBackID == id).First();
            db.FeedBacks.DeleteOnSubmit(a);
            db.SubmitChanges();
        }

        public static FeedBack GetByID(int id, HCDataContext db)
        {
            return db.FeedBacks.Where(
                ik => ik.FeedBackID == id).FirstOrDefault();
        }

        public static FeedBack GetByID(int id)
        {
            return GetByID(id, new HCDataContext());
        }
    }
}